#ifndef _CACHE_TABLE_H_
#define _CACHE_TABLE_H_
#include <sys/types.h>
#include "common.h"

#define MAX_CAHCE 32
struct cache_disk_part
{
	u_int32_t ip; /* big endian */
	char ipstr[16]; /* ip in string */
	int policy; /* policy for how to synchronize traffic */
#define P_DEPEND 0
#define P_MUST 1
#define P_MUST_NOT 2
	int disable;
};

struct cache_mem_part
{
	int state;
#define S_ALIVE 0
#define S_DEATH 1
	int free_space; /* the total free space of all partitions.
					if the P_MUST policy is set, 
					it is set to the max free_spaca mount all caches */
	struct system_info *sysinfo;

};

struct cache_table
{
	int nr_cache;
	struct cache_disk_part cache_d[MAX_CAHCE];
	struct cache_mem_part cache_m[MAX_CAHCE];
	int nr_public; /* the number of cache which can go to public network to
					  download data */
	int public_ability[MAX_CAHCE];
	int free_space_tt; /* total free space of the caches listed
						  in public_ability */
	int free_space_max; /* the max free space of caches listed 
						   in public_ability */
};

int load_cache(int *num, struct cache_disk_part cache[MAX_CAHCE]);
int save_cache(int num, struct cache_disk_part cache[MAX_CAHCE]);
int load_cache_table(struct cache_table *ct);

#endif
